<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>用户列表</title>

    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <%--引入样式--%>
    <%--先引入jQuery--%>
    <script src="<%=basePath%>/static/js/jquery-1.12.4.min.js" type="text/javascript"></script>
    <%--引入bootatrap样式--%>
    <link href="<%=basePath%>/static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <%--引入bootstarpjs文件--%>
    <script src="<%=basePath%>/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <%--标题--%>
    <h1>ssm_crud</h1>
        <%--按钮--%>
<div class="row">
<div class="col-md-4 col-md-offset-8">
    <button type="button" class="btn btn-success">新增</button>
    <button type="button" class="btn btn-danger">删除</button>
</div>
</div>

    <%--表格渲染数据--%>
<div class="row">
    <div class="col-md-12">
    <table class="table table-hover">
<thead>
<tr>
    <th>ID</th>
    <th>empName</th>
    <th>gender</th>
    <th>email</th>
    <th>deptName</th>
    <th>操作</th>
</tr>
</thead>
        <tbody>
        <c:forEach var="page" items="${pageInfos.list}">
            <tr>
                <td>${page.empId}</td>
                <td>${page.empName}</td>
                <td>${page.gender == "M" ? "男" : "女"}</td>
                <td>${page.email}</td>
                <td>${page.department.deptName}</td>
                <td>
                    <button type="button" class="btn btn-primary glyphicon glyphicon-pencil btn-sm">修改</button>
                    <button type="button" class="btn btn-primary glyphicon glyphicon-trash btn-sm">删除</button>
                </td>
            </tr>

        </c:forEach>
        </tbody>
    </table>
    </div>
</div>
    <div class="row">
        <%--分页信息--%>
        <div class="col-md-6">
            当前在${pageInfos.pageNum}页，共${pageInfos.pages}页，共${pageInfos.total}条记录
        </div>
        <%--分页条--%>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <%--要是当前页为第一页则禁用首页按钮和上一页按钮--%>
                    <c:if test="${pageInfos.hasPreviousPage==false}">
                        <li class="disabled"><a href="<%=basePath%>/employee/getEmployeeList?pageNum=1">首页</a></li>
                        <li class="disabled">
                            <a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>

                    </c:if>

                    <c:if test="${pageInfos.hasPreviousPage==true}">
                        <li><a href="<%=basePath%>/employee/getEmployeeList?pageNum=1">首页</a></li>
                        <li>
                            <a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>

                    </c:if>

                    <c:forEach items="${pageInfos.navigatepageNums}" var="page_num">
                        <%--判断当前页是哪一页，并给他高亮显示--%>
                        <c:if test="${pageInfos.pageNum==page_num}">
                            <li class="active"><a href="<%=basePath%>/employee/getEmployeeList?pageNum=${page_num}">${page_num}</a></li>
                        </c:if>

                        <c:if test="${pageInfos.pageNum!=page_num}">
                            <li><a href="<%=basePath%>/employee/getEmployeeList?pageNum=${page_num}">${page_num}</a></li>
                        </c:if>
                    </c:forEach>
                        <%--判断是否有下一页，没有就禁用掉下一页按钮和末页按钮--%>
                        <c:if test="${pageInfos.hasNextPage==false}">
                            <li class="disabled">
                                <a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pageNum+1}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                            <li class="disabled"><a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pages}">末页</a></li>

                        </c:if>

                        <c:if test="${pageInfos.hasNextPage==true}">
                            <li>
                                <a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pageNum+1}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                            <li><a href="<%=basePath%>/employee/getEmployeeList?pageNum=${pageInfos.pages}">末页</a></li>

                        </c:if>

                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
